/**
 * 
 */
package de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.feature_types;
import java.util.HashSet;
import java.util.Set;
import de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType;
/**
 * 
 * @author Christoph Teichmann
 * created Jun 3, 2014 4:19:38 PM
 * @version 0.1
 */
public class SuffixFeatures implements FeatureType
{
	/**
	 * 
	 */
	private final Set<String> options = new HashSet<>();
	/**
	 * @param length
	 */
	public SuffixFeatures(int length)
	{this.length = length;}
	/**
	 * 
	 */
	private final int length;
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#getFeatName(java.lang.String)
	 */
	@Override
	public String getFeatName(String s)
	{
		if(s.length() <= this.length)
		{s = s.toLowerCase();}
		else
		{s = s.toLowerCase().substring(s.length()-this.length,s.length());}
		this.options.add(s);
		return s;
	}
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#updateWeight(java.lang.String, boolean, double)
	 */
	@Override
	public double updateWeight(String s, boolean first, double d)
	{return first ? 1.0 : d+1.0;}
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#getFeatureOptions()
	 */
	@Override
	public Iterable<String> getFeatureOptions()
	{return this.options;}
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#getType()
	 */
	@Override
	public String getType()
	{return "multinomial";}
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#process(java.lang.String)
	 */
	@Override
	public String process(String s)
	{return s;}
	/* (non-Javadoc)
	 * @see de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.FeatureType#name()
	 */
	@Override
	public String name()
	{return "SUFFIXFEATURES";}
}